package com.ruoyi.test_tree.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.test_tree.domain.PlaceLocation;
import com.ruoyi.test_tree.service.IPlaceLocationService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 放置位置表Controller
 * 
 * @author ruoyi
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/test/tree_location")
public class PlaceLocationController extends BaseController
{
    @Autowired
    private IPlaceLocationService placeLocationService;

    /**
     * 查询放置位置表列表
     */
    @PreAuthorize("@ss.hasPermi('test:tree_location:list')")
    @GetMapping("/list")
    public AjaxResult list(PlaceLocation placeLocation)
    {
        List<PlaceLocation> list = placeLocationService.selectPlaceLocationList(placeLocation);
        return success(list);
    }

    /**
     * 导出放置位置表列表
     */
    @PreAuthorize("@ss.hasPermi('test:tree_location:export')")
    @Log(title = "放置位置表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlaceLocation placeLocation)
    {
        List<PlaceLocation> list = placeLocationService.selectPlaceLocationList(placeLocation);
        ExcelUtil<PlaceLocation> util = new ExcelUtil<PlaceLocation>(PlaceLocation.class);
        util.exportExcel(response, list, "放置位置表数据");
    }

    /**
     * 获取放置位置表详细信息
     */
    @PreAuthorize("@ss.hasPermi('test:tree_location:query')")
    @GetMapping(value = "/{locationId}")
    public AjaxResult getInfo(@PathVariable("locationId") Long locationId)
    {
        return success(placeLocationService.selectPlaceLocationByLocationId(locationId));
    }

    /**
     * 新增放置位置表
     */
    @PreAuthorize("@ss.hasPermi('test:tree_location:add')")
    @Log(title = "放置位置表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlaceLocation placeLocation)
    {
        return toAjax(placeLocationService.insertPlaceLocation(placeLocation));
    }

    /**
     * 修改放置位置表
     */
    @PreAuthorize("@ss.hasPermi('test:tree_location:edit')")
    @Log(title = "放置位置表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlaceLocation placeLocation)
    {
        return toAjax(placeLocationService.updatePlaceLocation(placeLocation));
    }

    /**
     * 删除放置位置表
     */
    @PreAuthorize("@ss.hasPermi('test:tree_location:remove')")
    @Log(title = "放置位置表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{locationIds}")
    public AjaxResult remove(@PathVariable Long[] locationIds)
    {
        return toAjax(placeLocationService.deletePlaceLocationByLocationIds(locationIds));
    }
}
